import random


# 定义扑克牌
class Poker:
    def __init__(self):
        self.suits = ['', '', '', '']
        self.values = ['3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A', '2']
        self.cards = [f'{value}{suit}' for suit in self.suits for value in self.values]
        self.cards.append('小王')
        self.cards.append('大王')
        random.shuffle(self.cards)

    def deal_cards(self, num):
        return [self.cards.pop() for _ in range(num)]


# 玩家类
class Player:
    def __init__(self, name):
        self.name = name
        self.hand = []

    def receive_cards(self, cards):
        self.hand.extend(cards)

    def play_card(self, card):
        if card in self.hand:
            self.hand.remove(card)
            return card
        else:
            return None


# 斗地主游戏类
class DouDiZhu:
    def __init__(self):
        self.poker = Poker()
        self.players = [Player('Player1'), Player('Player2'), Player('Player3')]
        self.landlord = None

    def start_game(self):
        # 发牌
        for _ in range(17):
            for player in self.players:
                player.receive_cards(self.poker.deal_cards(1))

        # 留三张底牌
        self.base_cards = self.poker.deal_cards(3)

        # 选择地主
        self.landlord = self.players[0]  # 简化示例，实际应通过叫地主流程确定

        # 剩余的牌给地主
        for card in self.poker.deal_cards(3):
            self.landlord.receive_cards([card])

        # 游戏开始，这里只是一个示例，实际需要更复杂的逻辑
        print(f"{self.landlord.name} is the landlord.")
        self.play_game()

    def play_game(self):
        # 这里只是一个示例，实际游戏需要更复杂的出牌和判断逻辑
        current_player = self.players[0]
        while True:
            print(f"{current_player.name}'s turn.")
            # 玩家出牌逻辑（省略）
            # 判断游戏是否结束（省略）
            # 切换玩家（省略）


# 开始游戏
game = DouDiZhu()
game.start_game()
